package enum_;

public class EnumTest {
    public static void main(String[] args) {
        System.out.println(WeekDay.FRIDAY);

        //valueOf
        WeekDay monday = WeekDay.valueOf("MONDAY");
        System.out.println(monday);

        //values方法:以数组的形式存储WeekDay里面的数据
        WeekDay[] values = WeekDay.values();
        for (WeekDay value : values) {
            System.out.println(value);
        }
        System.out.println("****************");
        judgeWeek(WeekDay.SATURDAY);
        judgeWeek2(WeekDay.MONDAY);


    }

    //枚举类型结合switch使用
    public static void judgeWeek(WeekDay weekDay) {
        switch (weekDay) {
            case MONDAY:
                System.out.println("这是周一");
                break;
            case TUESDAY:
                System.out.println("这是周二");
                break;
            case WENDESDAY:
                System.out.println("这是周三");
                break;
            case THURSDAY:
                System.out.println("这是周四");
                break;
            case FRIDAY:
                System.out.println("这是周五");
                break;
            case SATURDAY:
                System.out.println("这是周六");
                break;
            case SUNDAY:
                System.out.println("这是周日");
                break;
            default:
                System.out.println("输入不合法");
                break;
        }
    }

    //新写法
    public static void judgeWeek2(WeekDay weekDay) {
        switch (weekDay) {
            case MONDAY -> System.out.println("这是周一");
            //不用加break了
            case TUESDAY -> System.out.println("这是周二");
            case WENDESDAY -> System.out.println("这是周三");
            case THURSDAY -> System.out.println("这是周四");
            case FRIDAY -> System.out.println("这是周五");
            case SATURDAY -> System.out.println("这是周六");
            case SUNDAY -> System.out.println("这是周日");
        }
    }


}
